﻿Imports System.Windows.Forms

<Serializable()> Public Class LineTool
    Inherits BaseTool




    Dim m_Handler As Integer
    Dim tx, ty As Double

    Dim nx, ny As Double

    Dim mDown As Boolean = False

    Public mx, my As Double




    Public Overrides Sub mouseDown(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseDownEvent)

        'If Me.OperShapeProperty Is Nothing Then '第一次绘制



        '    Me.OperShapeProperty = ShapeFactory.getNewLineShape()


        '    Me.OperShapeProperty.P1Property = Me.DownPointProperty
        '    Me.OperShapeProperty.plist.Add(Me.DownPointProperty)



        'Else


        If e.button = 1 Then





            'End If
            mDown = True

            m_Handler = mapwin.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)

            mapwin.PixelToProj(e.x, e.y, tx, ty)
            mapwin.DrawCircleEx(m_Handler, tx, ty, 4, 128, True)

        End If


    End Sub

    Public Overrides Sub mouseDrag(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)

    End Sub

    Public Overrides Sub mouseMove(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)

        ' mapwin.ClearDrawing(m_Handler)
        If mDown Then
            mapwin.ClearDrawing(m_Handler)
            m_Handler = mapwin.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)

            mapwin.PixelToProj(e.x, e.y, nx, ny)

            mapwin.DrawCircleEx(m_Handler, tx, ty, 4, 128, True)
            mapwin.DrawLineEx(m_Handler, tx, ty, nx, ny, 1, 0)
            mapwin.DrawCircleEx(m_Handler, nx, ny, 4, 2000, True)




        End If

       

        'If Me.OperShapeProperty.plist.Count = 1 Then

        ' Dim pPos As New Drawing.Point(tx, ty)



        'ControlPaint.DrawReversibleLine(getScreen(pPos), getScreen(Me.OldmovepointProperty), lColor)

        'ControlPaint.DrawReversibleLine(getScreen(pPos), getScreen(Me.NewmovepointProperty), lColor)


        'End If
    End Sub

    Public Overrides Sub mouseUp(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseUpEvent)

        If mDown Then
            mDown = False

            mapwin.ClearDrawing(m_Handler)

            mx = nx - tx
            my = ny - ty

            InvokeEndDrawing()

        End If
      

        'Me.OperShapeProperty.plist.Add(Me.DownPointProperty)
        ''对于直线来讲，这里的绘制已经结束


        'InvokeEndDrawing()
        'Me.OperShapeProperty = Nothing


    End Sub

    Public Overrides Sub setself()

    End Sub

    Public Overrides Sub unSet()

    End Sub

    Public Overrides Sub mouseDblClick(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
End Class
